<template lang="">
  <t-dialog
    :visible="props.visibles"
    width="40%"
    header="新增申诉记录表"
    :confirm-loading="submitLoading"
    :destroy-on-close="true"
    @confirm="handleOnConfirm"
    @cancel="handleClose"
    @close="handleClose"
  >
    <t-form ref="form" :data="formData" :rules="rules">
      <t-form-item label="测站编码" name="STCD">
      <t-input v-model="formData.STCD" placeholder="请输入测站编码"></t-input>
    </t-form-item>
      <t-form-item label="断面名称" name="STNM">
      <t-input v-model="formData.STNM" placeholder="请输入断面名称"></t-input>
    </t-form-item>
      <t-form-item label="编号" name="LYNM">
      <t-input v-model="formData.LYNM" placeholder="请输入编号"></t-input>
    </t-form-item>
      <t-form-item label="采样时间" name="SPT">
      <t-input v-model="formData.SPT" placeholder="请输入采样时间"></t-input>
    </t-form-item>
      <t-form-item label="分析时间" name="FXT">
      <t-input v-model="formData.FXT" placeholder="请输入分析时间"></t-input>
    </t-form-item>
      <t-form-item label="异常数据" name="exceptionData">
      <t-input v-model="formData.exceptionData" placeholder="请输入异常数据"></t-input>
    </t-form-item>
      <t-form-item label="处理操作" name="handleOperate">
      <t-input v-model="formData.handleOperate" placeholder="请输入处理操作"></t-input>
    </t-form-item>
      <t-form-item label="修改后的值" name="updateValue">
      <t-input v-model="formData.updateValue" placeholder="请输入修改后的值"></t-input>
    </t-form-item>
      <t-form-item label="处理人员" name="operaterName">
      <t-input v-model="formData.operaterName" placeholder="请输入处理人员"></t-input>
    </t-form-item>
      <t-form-item label="处理说明" name="operateText">
      <t-input v-model="formData.operateText" placeholder="请输入处理说明"></t-input>
    </t-form-item>
      <t-form-item label="处理时间" name="operateDate">
      <t-input v-model="formData.operateDate" placeholder="请输入处理时间"></t-input>
    </t-form-item>
      <t-form-item label="审核人员" name="checkName">
      <t-input v-model="formData.checkName" placeholder="请输入审核人员"></t-input>
    </t-form-item>
      <t-form-item label="审核说明" name="checkText">
      <t-input v-model="formData.checkText" placeholder="请输入审核说明"></t-input>
    </t-form-item>
      <t-form-item label="审核时间" name="checkDate">
      <t-input v-model="formData.checkDate" placeholder="请输入审核时间"></t-input>
    </t-form-item>
      </t-form>
  </t-dialog>
</template>
<script lang="ts" setup>
import { MessagePlugin } from 'tdesign-vue-next';
import { onMounted, reactive, ref } from 'vue';

import {getList, getInfo, doDelete, doUpdate, doCreate } from '@/api/platform/waterquality/appeal/record';

const props = defineProps({
  visibles: {
    type: Boolean,
    default: false,
  },
});
const INITIAL_DATA = {
        STCD: '',
        STNM: '',
        LYNM: '',
        SPT: '',
        FXT: '',
        exceptionData: '',
        handleOperate: '',
        updateValue: '',
        operaterName: '',
        operateText: '',
        operateDate: '',
        checkName: '',
        checkText: '',
        checkDate: '',
  };
const form = ref();
const submitLoading = ref(false);
const formData: any = reactive({
  ...INITIAL_DATA,
});
const rules = reactive({
        STCD: [
      {
        required: true,
        message: '测站编码必填',
        type: 'error',
        trigger: 'blur',
      },],
        STNM: [
      {
        required: true,
        message: '断面名称必填',
        type: 'error',
        trigger: 'blur',
      },],
        LYNM: [
      {
        required: true,
        message: '编号必填',
        type: 'error',
        trigger: 'blur',
      },],
        SPT: [
      {
        required: true,
        message: '采样时间必填',
        type: 'error',
        trigger: 'blur',
      },],
        FXT: [
      {
        required: true,
        message: '分析时间必填',
        type: 'error',
        trigger: 'blur',
      },],
        exceptionData: [
      {
        required: true,
        message: '异常数据必填',
        type: 'error',
        trigger: 'blur',
      },],
        handleOperate: [
      {
        required: true,
        message: '处理操作必填',
        type: 'error',
        trigger: 'blur',
      },],
        updateValue: [
      {
        required: true,
        message: '修改后的值必填',
        type: 'error',
        trigger: 'blur',
      },],
        operaterName: [
      {
        required: true,
        message: '处理人员必填',
        type: 'error',
        trigger: 'blur',
      },],
        operateText: [
      {
        required: true,
        message: '处理说明必填',
        type: 'error',
        trigger: 'blur',
      },],
        operateDate: [
      {
        required: true,
        message: '处理时间必填',
        type: 'error',
        trigger: 'blur',
      },],
        checkName: [
      {
        required: true,
        message: '审核人员必填',
        type: 'error',
        trigger: 'blur',
      },],
        checkText: [
      {
        required: true,
        message: '审核说明必填',
        type: 'error',
        trigger: 'blur',
      },],
        checkDate: [
      {
        required: true,
        message: '审核时间必填',
        type: 'error',
        trigger: 'blur',
      },],
  });
onMounted(() => {
});
const emit = defineEmits(['update:visibles', 'success']);

const handleOnConfirm = () => {
  form.value.validate().then((validateResult: any) => {
    if (validateResult === true) {
      submitLoading.value = true;
      doCreate({
        ...formData,
      }).then(() => {
        submitLoading.value = false;
        MessagePlugin.success('新增申诉记录表成功');
        form.value.clearValidate();
        form.value.reset();
        handleClose();
        emit('success');
      });
    } else {
      MessagePlugin.error('表单验证失败');
    }
  });
};

const handleClose = () => {
  emit('update:visibles', false);
};
</script>
<style lang="less" scoped></style>
